package main

import (
	"fmt"
	"net"
	"time"
)

func main() {


	conn, errDialErr := net.Dial("tcp", "127.0.0.1:80")

	if errDialErr != nil {
		fmt.Println("errDial error ....", errDialErr)
	}

	go func() {
		massageBody := make([] byte, 1024*8)

		for {

			n, _ := conn.Read(massageBody)

			fmt.Println("收到消息:", string(massageBody[0:n]))
		}

	}()


	var msg string


	for {

		fmt.Scan(&msg)

		fmt.Println("发送消息:", msg)

		conn.Write([]byte(msg))
	}

	time.Sleep(time.Second * 2)
}
